package com.ymk.base.cmd;

import javax.servlet.http.HttpServletRequest;

public interface ICommand {

    /**
     * 处理逻辑
     *
     * @param request
     * @param sign
     * @return
     * @throws Exception
     */
    CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception;

    CmdSign executeMop(HttpServletRequest request, CmdSign sign) throws Exception;

    CmdSign executeSop(HttpServletRequest request, CmdSign sign) throws Exception;

    CmdSign executeStore(HttpServletRequest request, CmdSign sign) throws Exception;

    CmdSign executeServer(HttpServletRequest request, CmdSign sign) throws Exception;


    /**
     * 路由处理
     *
     * @param request
     * @param sign
     * @return
     * @throws Exception
     */
    CmdSign route(HttpServletRequest request, CmdSign sign) throws Exception;

    /**
     * 命令编号
     *
     * @return
     */
    String getCmdCode();

    /**
     * 命令scope
     *
     * @return
     */
    String getDomain();

    /**
     * 是否允许匿名调用
     *
     * @return
     */
    boolean anon(CmdSign sign);

    /**
     * 开启事务
     *
     * @return
     */
    boolean openTx(CmdSign sign);

    /**
     * 验证
     *
     * @return
     */
    CmdSign verify(HttpServletRequest request, CmdSign sign) throws Exception;

    /**
     * 需要执行的下一个指令
     *
     * @return
     */
    String nextCmd();

    /**
     * 打开审计日志-执行前
     *
     * @return
     */
    boolean openAuditLogBefore();

    /**
     * 打开审计日志-执行后
     *
     * @return
     */
    boolean openAuditLogAfter();

    /**
     * 审计日志-业务号
     *
     * @param reqSign
     * @param respSign
     * @return
     */
    String auditLogBizNo(CmdSign reqSign, CmdSign respSign);


    /**
     * 审计日志-获取数据
     *
     * @param respSign
     * @return
     */
    Object getAuditLogData(CmdSign respSign);

    String lockKey(CmdSign sign);
}
